'use strict';
const bcrypt = require('bcryptjs');

module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Score = app.model.define(
    'score',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      student_id: INTEGER(11),
        category_id: INTEGER(11),
        course_id: INTEGER(11),
      teacher_id: INTEGER(11),
        type: STRING(255),
        score1: STRING(255),
        score2: STRING(255),
        score3: STRING(255),
        score4: STRING(255),
        desc: STRING(255),
    },
    {
      tableName: 'score',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );
    Score.associate = () => {
        const { Student, Course,Teacher } = app.model;
        Score.hasOne(Student, {foreignKey: 'id', sourceKey: 'student_id'})
        Score.hasOne(Course, {foreignKey: 'id', sourceKey: 'course_id'})
        Score.hasOne(Teacher, {foreignKey: 'id', sourceKey: 'teacher_id'})
    };
  return Score;
};
